<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.User>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Edit User</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

   <script type="text/javascript">
       $(document).ready(function() {
           $("#UserForm").validate({
               rules: {
                   UserName: {
                       required: true
                   },
                   Email: {
                       required: true,
                       email: true
                   },
                   FName: {
                       required: true
                   },
                   LName: {
                       required: true
                   }
               },
               messages: {
                   UserName: {
                       required: "UserName cannot be blank"
                   },
                   Email: {
                       required: "Email cannot be blank",
                       email: "Email must be valid"
                   },
                   FName: {
                       required: "First Name cannot be blank"
                   },
                   LName: {
                       required: "Last Name cannot be blank"
                   }
               }
           });
           $("#submit_view").click(function() {
               $("#IsRedirectToView").val("true");
           });
       });
    </script>

    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
    <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->
    <br />
    <br />
    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm("Edit", "User", FormMethod.Post, new { id = "UserForm" }))
       {%>
    <fieldset>
        <legend>Create User</legend>
        <p>
            <label for="LogInID">
                LogIn ID:
            </label>
            <%= Model.LogInID %>
        </p>
        <p>
            <label for="FName">
                First Name:</label>
            <%= Html.TextBox("FName")%>
        </p>
        <p>
            <label for="LName">
                Last Name:</label>
            <%= Html.TextBox("LName")%>
        </p>
        <p>
            <label for="Email">
                Email:</label>
            <%= Html.TextBox("Email")%>
            <%= Html.ValidationMessage("Email", "*")%>
        </p>
        <p>
            <label for="HPhone">
                Phone:</label>
            <%= Html.TextBox("HPhone")%>
            <%= Html.ValidationMessage("HPhone")%>
        </p>
        <p>
            <label for="Options">
            </label>
            <select id="Options" name="Options">
                <% switch (Model.Options)
                   {
                       case "HomeOwner": %>
                <option value="HomeOwner" selected="selected">HomeOwner</option>
                <option value="Leaser">Leaser</option>
                <%
                    break;
                       case "Leaser": %>
                <option value="HomeOwner">HomeOwner</option>
                <option value="Leaser" selected="selected">Leaser</option>
                <%
                    break;
                       default:
                %>
                <option value="HomeOwner">HomeOwner</option>
                <option value="Leaser">Leaser</option>
                <%
                    break;
                   }  
                %>
            </select>
        </p>
        <p>
            <label for="Address1">
                Slot number or Address:</label>
            <%= Html.TextBox("Address1")%>
        </p>
       <p>       
            <label for="Role">
                RoleName:</label>
            <%= Html.DropDownList("RoleName") %>       
        </p>
        <p>
         <label for="NewsLetter">
                Receive NewsLetter from <%= System.Configuration.ConfigurationManager.AppSettings["SiteName2"] %>:</label>
            <%= Html.CheckBox("NewsLetter")%>
            <%= Html.ValidationMessage("NewsLetter", "*")%>
        </p>
        <p>
            <label for="Active">
                Active:</label>
            <%= Html.CheckBox("Active", Model.Active) %>
            <%= Html.ValidationMessage("Active", "*") %>
        </p>
        <p>
            <%= Html.Hidden("IsRedirectToView")%>
            <input id="submit" name="submit" type="submit" value="Update" />
            <input id="submit_view" name="submit_view" type="submit" value="Update & View" />
            <input type="reset" value="Reset" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>
</asp:Content>
